package main

import (
	"fmt"
	"sync"
)

var wg = sync.WaitGroup{}

func main() {

	var chan1 chan int = make(chan int, 2)
	wg.Add(1)
	go func() {
		defer wg.Done()
		for {
			fmt.Println(<-chan1)
		}
	}()
	chan1 <- 1
	chan1 <- 2
	// chan1 <- 3
	close(chan1)
	wg.Wait()
}
